<section id="content">
  <div class="block">
    <header>
      <?php if (Auth::instance()->logged_in() && $userAuth->username === $photo_user->username): ?>
      <div class="top-right text-gray"><strong><a class="href-gray" href="<?php echo url::base() ?>photo/edit/<?php echo $photo_user->id ?>" title="Upravit vlastnosti tohoto náhledu">Upravit</a></strong> | <strong><a class="href-gray" id="photoDelete" href="javascript:;" title="Všechny fotografie v tomto náhledu budou smazány">Smazat fotografie</a></strong></div>
      <?php endif ?>
      <h2><?php echo $photo_user->title; ?></h2>
    </header>
    <!-- HTML5 sekce pro fotografie -->
    <section class="block-body">
      <p><?php echo $photo_user->description; ?></p>
      <div id="photo-images">
      <?php foreach ($photo_user->photo_source->find_all() as $item): ?>
        <img class="full-photo-open" src="<?php echo url::base() ?>files/users/<?php echo $photo_user->username; ?>/<?php echo $item->filename; ?>" alt="" />
      <?php endforeach ?>
      </div>
    </section>
  </div>
  <div class="block-bottom"></div>
  <?php if (count($comments_photo) !== 0 || Auth::instance()->logged_in()): ?>
  <div class="block">
    <header>
      <h2>Komentáře</h2>
    </header>
    <!-- HTML5 sekce pro komentáře -->
    <section class="block-body">
      <?php if (Auth::instance()->logged_in() && $photo_user->user_comments_allowed == true): ?>
      <form action="<?php echo url::base(); ?>comments/photo_add" method="post">
        <ul>
          <li>
            <textarea cols="10" rows="10" name="ctext" class="text-big"></textarea>
          </li>
          <li class="submit"><?php echo Form::submit(NULL, 'Přidat komentář'); ?></li>
        </ul>
        <?php echo Form::hidden('pid', $photo_user->id); ?>
      </form>
      <?php endif ?>
      <?php foreach ($comments_photo as $item): ?>
      <div class="comment"><?php echo nl2br($item->text); ?></div>
      <div class="comment-bottom"><?php echo $item->username .' ('.Helpers_Photovoice::datum($item->date). ')'; ?></div>
      <?php endforeach ?>
      <br />
      <div class="clear-both"></div>
    </section>
  </div>
  <div class="block-bottom"></div>
  <?php endif ?>
</section>
<div id="full-photo-canvas">
  <div id="full-photo-top">
    <div id="full-photo-change" class="full-photo-navigation">
      <a title="Změnit pozadí">Světlé pozadí</a>
    </div>
    <?php if ($photo_user->photo_source->count_all() > 1): ?>
    <div class="full-photo-navigation">      
      <a id="full-photo-prev" class="separate" title="Přejít na předchozí fotografii">Předchozí fotografie</a><span></span>
      <a id="full-photo-next" title="Přejít na další fotografii">Další fotografie</a>      
    </div>
    <?php endif ?>
    <div id="full-photo-close" class="full-photo-navigation">
      <a title="Zavřít náhled">Zavřít</a>
    </div>
  </div>
  <div id="full-photo-content">    
    <div id="full-photo-images">
      <ul>
      <?php $item_pos=1; foreach ($photo_user->photo_source->find_all() as $item): ?>
        <li <?php if ($item_pos == 1) {echo 'class="active"';} ?>>
          <?php if (file_exists('files/users/'.$photo_user->username.'/o_'.$item->filename)): ?>
          <img src="<?php echo url::base() ?>files/users/<?php echo $photo_user->username; ?>/o_<?php echo $item->filename; ?>" alt="" />
          <?php else: ?>
          <img src="<?php echo url::base() ?>files/users/<?php echo $photo_user->username; ?>/<?php echo $item->filename; ?>" alt="" />
          <?php endif ?>
        </li>
      <?php $item_pos++; endforeach ?>
      </ul>
    </div>
  </div>
</div>
<?php if ($photo_user->mature_content && !Auth::instance()->logged_in()): ?>
<style type="text/css">
  .ui-widget-overlay { background: #f8f7f5; opacity: 1; filter: alpha(opacity=100) }
</style>
<div id="dialog-confirm" title="18+">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>Tato fotografie je přístupná pouze osobám starší 18 let.</p>
</div>
<script>
  $(function() {

    $( "#dialog-confirm" ).dialog({
      resizable: false,
      width: 400,
      modal: true,
      draggable: false,
      closeOnEscape: false,
      open: function(event, ui) { $(".ui-dialog-titlebar-close").remove(); },
      buttons: {
        "Již mám 18 let": function() {
          $( this ).dialog( "close" );
        },
        "Odejít": function() {
          window.location.replace("/");
        }
      }
    });
  });
</script>
<?php endif ?>

<?php if (Auth::instance()->logged_in() && $userAuth->username === $photo_user->username): ?>
<script>
  $(function() {    
    $("#dialog-confirm-delete").hide();

    $("a#photoDelete").click(function () {
      $("#dialog-confirm-delete").dialog({
        resizable: false,
        width: 400,
        minHeight: 40,
        modal: true,
        draggable: false,
        closeOnEscape: true,
        open: function(event, ui) { $(".ui-dialog-titlebar-close,.ui-dialog-titlebar").remove(); },
        buttons: {
          "Odstranit": function() {
            window.location.replace("<?php echo url::base(); ?>photo/delete/<?php echo $photo_user->id ?>");
          },
          "Zavřít": function() {
            $( this ).dialog( "close" );
          }
        }
      });
    });

  });
</script>
<div id="dialog-confirm-delete">
  <p>Skutečně chcete tyto fotografie odtranit?</p>
</div>
<?php endif ?>

